package com.example.chat2.service;

import com.example.chat2.dao.UserinfoMapper;
import com.example.chat2.domain.TbUserinfo;

import com.example.chat2.vo.AuthUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserinfoService {
    /**
     *
     */
    @Autowired
    UserinfoMapper userinfoMapper;


    public List<TbUserinfo> getUserinfosList(){
        List<TbUserinfo>     list=  userinfoMapper.selectAll();


        return  list;
    }
    /**
     * 根据主键查询
     * @param id
     * @return
     */
    public TbUserinfo getUserinfoById(Long  id){
        TbUserinfo userinfo =  userinfoMapper.selectByPrimaryKey1(id);
        return  userinfo;
    }
    /**
     *登录
     */

    public TbUserinfo login(AuthUserVo authUserVo){

        return userinfoMapper.selectByUserAndPassword(authUserVo);
    }


    /**
     *登录
     */


    /**
     * 注册
     */
    public  TbUserinfo register(TbUserinfo tbUserinfo){
        userinfoMapper.insert(tbUserinfo);

        return tbUserinfo;
    }
}
